function OtherCustom() {
};

OtherCustom.instance = function() {
  var popupBox = new PopupBox(), _self = this;
  var popupBox2 = new PopupBox2();
  
  var model = Model.instance('{{$smarty.const.MODEL_NAME_CUSTOM|escape:javascript}}', '{{$smarty.const.MODEL_TITLE_CUSTOM|escape:javascript}}', '{{$smarty.const.MODEL_TYPE_CUSTOM|escape:javascript}}');
  
  //Create model here...
  var state1 = State.instance(model, 0, 'not activate');
  var state2 = State.instance(model, 1, 'New Task');
  var state3 = State.instance(model, 2, 'Questioned');
  var state4 = State.instance(model, 3, 'Reopened');
  var state5 = State.instance(model, 4, 'Task is completed');
  var state6 = State.instance(model, 5, 'Task is comfirmed');
  var transition1 = Transition.instance('done', state2, state5, null, DlmanageUtils.mixed, 1);
  var transition2 = Transition.instance('ask', state2, state3, null, DlmanageUtils.mixed, 3);
  var transition3 = Transition.instance('answer', state3, state4, null, DlmanageUtils.mixed, 3);
  var transition4 = Transition.instance('done', state4, state5, null, DlmanageUtils.mixed, 1);
  var transition5 = Transition.instance('ask', state4, state3, null, DlmanageUtils.mixed, 3);
  var transition6 = Transition.instance('confirm', state5, state6, null, DlmanageUtils.none);
  var transition7 = Transition.instance('cancel', state1, state1, null, null, null);
  var transition8 = Transition.instance('cancel', state2, state2, null, null, null);
  var transition9 = Transition.instance('cancel', state3, state3, null, null, null);
  var transition10 = Transition.instance('cancel', state4, state4, null, null, null);
  var transition11 = Transition.instance('cancel', state5, state5, null, null, null);

  transition1.validate = function(produce, user, date, options) { if (produce.user_trackId == user.trackId) { return true; } else { return false; } };
  transition2.validate = function(produce, user, date, options) { if (produce.user_trackId == user.trackId) { return true; } else { return false; } };
  transition3.validate = function(produce, user, date, options) { if (produce.ownerTrackId == user.trackId) { return true; } else { return false; } };
  transition4.validate = function(produce, user, date, options) { if (produce.user_trackId == user.trackId) { return true; } else { return false; } };
  transition5.validate = function(produce, user, date, options) { if (produce.user_trackId == user.trackId) { return true; } else { return false; } };
  transition6.validate = function(produce, user, date, options) { if (produce.ownerTrackId == user.trackId) { return true; } else { return false; } };
  transition7.validate = function(produce, user, date, options) { if (produce.ownerTrackId == user.trackId) { return true; } else { return false; } };
  transition8.validate = function(produce, user, date, options) { if (produce.ownerTrackId == user.trackId) { return true; } else { return false; } };
  transition9.validate = function(produce, user, date, options) { if (produce.ownerTrackId == user.trackId) { return true; } else { return false; } };
  transition10.validate = function(produce, user, date, options) { if (produce.ownerTrackId == user.trackId) { return true; } else { return false; } };
  transition11.validate = function(produce, user, date, options) { if (produce.ownerTrackId == user.trackId) { return true; } else { return false; } };

  transition2.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var func1 = function() { if (produce._text == '') {
                                                                                                               window.alert('CAN NOT BE EMPTY');
                                                                                                               return;
                                                                                                             }
                                                                                                             if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.extra = produce._text;
                                                                                                             DlmanageUtils.operate(transition2, pos, callbackFunc, produce, user, date, options);
                                                                                                             popupBox2._close();
                                                                                                           };
                                                                                    var func2 = function() { popupBox2._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox2, pos, div, func1, func2, {t: '请写下 问题内容', func: function() { callbackFunc(); } });
                                                                                    new DialogInput(div, produce, { title: '' });
                                                                                  };
  
  transition3.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var func1 = function() { if (produce._text == '') {
                                                                                                               window.alert('CAN NOT BE EMPTY');
                                                                                                               return;
                                                                                                             }
                                                                                                             if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.extra = produce._text;
                                                                                                             DlmanageUtils.operate(transition3, pos, callbackFunc, produce, user, date, options);
                                                                                                             popupBox2._close();
                                                                                                           };
                                                                                    var func2 = function() { popupBox2._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox2, pos, div, func1, func2, {t: '请写下回复内容', func: function() { callbackFunc(); } });
                                                                                    new DialogInput(div, produce, { title: '' });
                                                                                  };
  transition5.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var func1 = function() { if (produce._text == '') {
                                                                                                               window.alert('CAN NOT BE EMPTY');
                                                                                                               return;
                                                                                                             }
                                                                                                             if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.extra = produce._text;
                                                                                                             DlmanageUtils.operate(transition5, pos, callbackFunc, produce, user, date, options);
                                                                                                             popupBox2._close();
                                                                                                           };
                                                                                    var func2 = function() { popupBox2._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox2, pos, div, func1, func2, {t: '请写下 问题内容', func: function() { callbackFunc(); } });
                                                                                    new DialogInput(div, produce, { title: '' });
                                                                                  };
                                                                              
  transition7.operate = function(pos, callbackFunc, produce, user, date, options) { produce.cancelled = 1; new RequestUtils()._write('produce', [produce], [], function() { callbackFunc(); }, { php: '{{$smarty.const.FACTORY|escape:javascript}}/jsonwrite.php', pos: pos }); };
  transition8.operate = function(pos, callbackFunc, produce, user, date, options) { produce.cancelled = 1; new RequestUtils()._write('produce', [produce], [], function() { callbackFunc(); }, { php: '{{$smarty.const.FACTORY|escape:javascript}}/jsonwrite.php', pos: pos }); };
  transition9.operate = function(pos, callbackFunc, produce, user, date, options) { produce.cancelled = 1; new RequestUtils()._write('produce', [produce], [], function() { callbackFunc(); }, { php: '{{$smarty.const.FACTORY|escape:javascript}}/jsonwrite.php', pos: pos }); };
  transition10.operate = function(pos, callbackFunc, produce, user, date, options) { produce.cancelled = 1; new RequestUtils()._write('produce', [produce], [], function() { callbackFunc(); }, { php: '{{$smarty.const.FACTORY|escape:javascript}}/jsonwrite.php', pos: pos }); };
  transition11.operate = function(pos, callbackFunc, produce, user, date, options) { produce.cancelled = 1; new RequestUtils()._write('produce', [produce], [], function() { callbackFunc(); }, { php: '{{$smarty.const.FACTORY|escape:javascript}}/jsonwrite.php', pos: pos }); };

  model.states = [ state1, state2, state3, state4, state5 , state6];
  model.transitions = [ transition1, transition2, transition3, transition4, transition5, transition6, transition7, transition8, transition9, transition10, transition11];
  return model;
};
